//
//  SecondStamentOfIncomeAndExpandingController.m
//  DYKT
//
//  Created by 陈雷 on 2017/7/21.
//  Copyright © 2017年 windo. All rights reserved.
//

#import "SecondStamentOfIncomeAndExpandingController.h"
#import "StamentOfIncomeAndExpandCell.h"

@interface SecondStamentOfIncomeAndExpandingController ()<UITableViewDelegate,UITableViewDataSource>

@property (nonatomic,strong) UITableView *tbv;
@property (strong, nonatomic) IBOutlet UIView *headerV;
@property (nonatomic,strong) NSArray *leftArr;
@property (nonatomic,strong) NSArray *dataArr;

@property (weak, nonatomic) IBOutlet UILabel *totoalLb;

@property (weak, nonatomic) IBOutlet UILabel *timeLb;


@end

@implementation SecondStamentOfIncomeAndExpandingController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    
    self.timeLb.text = [NSString stringWithFormat:@"%@ 收益",self.dateStr];
    self.leftArr = @[@"转运学院观看券转让",@"父母大学观看券转让",@"国学会员增益",@"收到的学分"];
    
    [self loadData];//加载数据
    
    [self baseConfig];
}

- (void)baseConfig{
    
    self.title = @"收益详情";
    
    self.tbv = [[UITableView alloc]initWithFrame:CGRectMake(0, 0, KSCreenWidth, KSCreenHeight - 64) style:UITableViewStyleGrouped];
    self.tbv.delegate = self;
    self.tbv.dataSource = self;
    [self.view addSubview:self.tbv];
    
    self.tbv.separatorColor = [UIColor colorWithHexString:@"eeeeee"];
    self.tbv.tableFooterView = [UIView new];
    [self.tbv registerNib:[UINib nibWithNibName:@"StamentOfIncomeAndExpandCell" bundle:nil] forCellReuseIdentifier:@"StamentOfIncomeAndExpandCell"];
    self.tbv.separatorInset = UIEdgeInsetsZero;
    self.headerV.frame = CGRectMake(0, 0, KSCreenWidth, 85);
    
}

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
    switch (indexPath.section) {
        case 0:
            return 85;
            break;
        default:
            return 50;
            break;
    }
}

- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{
    
    if (section == 0) {
        return .001;
    }
    return 10;
}

- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section{
    return .001;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    
    switch (section) {
        case 0:
            return 1;
            break;
            
        default:
            return self.leftArr.count;
            break;
    }
}

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
    
    return 2;
    
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    
    if (indexPath.section == 0) {
        UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"UITableViewCell"];
        if (!cell) {
            cell = [[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"UITableViewCell"];
            [cell addSubview:self.headerV];
        }
        cell.selectionStyle = UITableViewCellSelectionStyleNone;
        return cell;
    }
    
    StamentOfIncomeAndExpandCell *cell = [tableView dequeueReusableCellWithIdentifier:@"StamentOfIncomeAndExpandCell" forIndexPath:indexPath];
    cell.priceL.tag = 10000 + indexPath.row;
    
    cell.selectionStyle = UITableViewCellSelectionStyleNone;
    cell.rightArrowImv.hidden = YES;
    cell.timeL.text = self.leftArr[indexPath.row];
    return cell;
    
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    
    NSLog(@"section---%d, row---%d",indexPath.section,indexPath.row);
    
}


#pragma mark- 加载数据
- (void)loadData{
    
//    NSString * url=[NSString stringWithFormat:BASE_URL,@"800811"];
//    
//    NSDictionary *paramDic = @{@"date":self.dateStr};
//    
//    NSString *paramStr = [JFDic_StringTransform dictionaryToJson:paramDic];
//    
//    [[EatShowUtil shareNetWork]getDataByAFPost:url parameters:paramStr success:^(NSDictionary *dic) {
//        
//        self.totoalLb.text = [NSString stringWithFormat:@"%.2f",[dic[@"shouYiSumList"][@"sum"] floatValue]];
//        
//        
//        self.dataArr = dic[@"shouYiSumList"][@"list"];
//        
//        if (self.dataArr.count > 0) {
//            for (int i = 0; i < self.dataArr.count; i ++) {
//                
//                NSDictionary *dataDic = self.dataArr[i];
//                UILabel *lb = [self.tbv viewWithTag:10000 + i];
//                lb.text = [NSString stringWithFormat:@"+%2.f",[dataDic[@"xueFen"] floatValue]];
//            }
//        }
//
//        [self.tbv reloadData];//加载完数据刷新单元格
//        
//    } dataError:^(NSString *dataerror) {
//        
//    } netError:^(NSDictionary *errdic) {
//        
//    }];
    
}


@end
